<script setup>
import {onMounted, ref} from "vue";
import {doGet} from "../util/HttpClient.js";
import router from "../router/router.js";

let operatorMenus = ref([])

onMounted(() =>{
  doGet('/operator/menus').then((resp) =>{
    if (resp.data.code == 1000){
      operatorMenus.value = resp.data.data
    }else {
      alert('没有数据传输')
    }
  })
})

//菜单单击
const menuClick = (menu) => {
  router.push({
    path:'/frame/'+menu.url
  })
}
</script>

<template>
  <div>
    <el-row :gutter="20">
      <el-col :span="24" :offset="0">
        <el-menu default-active="M00301">
          <el-sub-menu
              v-for="submenu in operatorMenus"
              :index="submenu.number"
              :key="submenu.number"
          >
            <template #title>{{ submenu.name }}</template>
            <el-menu-item
                v-for="item in submenu.items"
                :index="item.number"
                :key="item.number"
                @click="menuClick(item)"
            >
              {{ item.name }}
            </el-menu-item>
          </el-sub-menu>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>

<style scoped>

</style>